package top.yesz.home.aspect;

import top.yesz.home.pojo.User;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.List;

@Aspect
@Component
public class TestAspect {
    @AfterReturning(value = "execution(* top.yesz.home.service.impl.GoServiceImpl.aspectCommit(..))", returning = "result")
    public void aspectCommit(JoinPoint joinPoint, Object result) {
        System.out.println("aspectCommitTransmit 执行后置通知");
        // 在这里可以对方法返回的结果进行处理
        if (result instanceof List) {
            List<Object> users = (List<Object>) result;
            System.out.println(users.get(0));
            User user2 = (User) users.get(1);
            User user3 = (User) users.get(2);
            System.out.println(user2);
            System.out.println(user3);
        }
    }
}
